package com.qf.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class MQConnUtil {
    public static Connection getConn() throws IOException, TimeoutException {
        //1. ConnectionFactory
        ConnectionFactory factory = new ConnectionFactory();

        //2. 设置连接信息
        factory.setHost("192.168.41.41");
        factory.setPort(5672);
        factory.setUsername("2002");
        factory.setPassword("2002");
        factory.setVirtualHost("2002");

        //3. 从工厂获取连接对象
        Connection connection = factory.newConnection();

        //4. 返回
        return connection;
    }

}
